var toyApp=angular.module('toyApp');
	toyApp.controller('orderbackCtl', [
	'$state',
	'$scope',
	'toyService',
	'broadcastBetweenCtrls',
	function($state,$scope,toyService,broadcastBetweenCtrls){
		$scope.queryorderid='';
		$scope.$on('ADD_ORDER_BACK_SUCCESS',function(){
			queryorder();
		});
		$scope.setorderId=function(orderid){
			$scope.neworderid=orderid;
		}
		$scope.orderback=function(){
			toyService('orderback',function(res){
				if(!res.success){
					 return false;
				}else{
					alert('回库成功，可进行上架操作！');
					$scope.$broadcast('ADD_ORDER_BACK_SUCCESS');
				
				}},{
					orderid:$scope.neworderid,
					rexcode:$scope.newexpresscode,
					lostdesc:$scope.newlostdesc
				});
			};
			$scope.searchByorderId=function(){
				queryorder();
			};
		 var queryorder=function(orderid){
		 	toyService('queryOrderBackList',function(res){
				if(!res.success){
					 return false;
				}
				else{
					$scope.orderlist=res.info;
				
				}},{
					orderid:$scope.queryorderid
				});
		};
		$scope.timeStamp=new Date().getTime();
		$scope.$watch('timeStamp',function(){
		queryorder();
	});
	}]);